<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="html" version="xhtml1.0" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
	
	<xsl:template match="ROOT">
		<html>
			<head>
			</head>
			<body>
				<h1>My Blog</h1>
				<xsl:apply-templates select="news"/>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="news">
		<div id="news">
			<xsl:apply-templates select="new"/>
		</div>
	</xsl:template>
	<xsl:template match="new">
		<xsl:variable name="id" select="id_user"/>
		<h2><xsl:value-of select="title"/></h2>
		<p><xsl:value-of select="body"/></p>
		<p><b>Auteur :</b> <xsl:value-of select="//users/user[@id=$id]/username"/></p>
		<p>Commentaire :</p>
		<ul>
			<xsl:for-each select="//comments/comment">
			<xsl:variable name="id2" select="@id"/>
				<xsl:if test="id_news=$id2">
					<xsl:variable name="comment_id" select="id_user"/>
					<li><xsl:value-of select="//users/user[@id=$comment_id]/username"/> - <xsl:value-of select="//comments/comment/body"/></li>				
				</xsl:if>
			</xsl:for-each>
		</ul>
		
	</xsl:template>
	
</xsl:stylesheet>